
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static int t;
    public static char[] s=new char[12];
    public static int[] d=new int[]{1,2,3,4,6,12};
    public static Map<Integer,Integer> res=new HashMap<>();
    public static boolean check(int a,int b){
        boolean flag=false;
        for(int i=0;i<b;i++){
            int j;
            for(j=0;j<a;j++){
                if(s[j*b+i]!='X') {
                    break;
                }
            }
            if(j==a){
                flag=true;
            }
        }
        return flag;
    }
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        t=cin.nextInt();
        while(t-->0){
            int cnt=0;
            res.clear();
            s=cin.next().toCharArray();
            for(int i=0;i<6;i++){
                if(check(d[i],12/d[i])){
                    cnt++;
                    res.put(d[i],12/d[i]);
                }
            }
            System.out.print(cnt);
            for(Map.Entry<Integer,Integer> entry:res.entrySet()){
                System.out.print(" "+entry.getKey()+"x"+entry.getValue());
            }
            System.out.println();
        }
    }
}
